package cn.cvs.controller;


import cn.cvs.dto.LoginUserDto;
import cn.cvs.service.LoginUserService;

import cn.cvs.vo.LoginUserVo;
import cn.cvs.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



@RestController
//@CrossOrigin
public class LoginController {
    @Autowired
    LoginUserService userService;

    //vo 后端返回前端要展示的数据
    //dto 后端接收的数据
    @PostMapping("/login")
    public ResultVo login(@RequestBody LoginUserDto userDto) {
       LoginUserVo vo=null;//token令牌存数据，
       try{
           vo= userService.login(userDto);
           return ResultVo.success("登录成功", vo);
       }catch (Exception e){
           e.printStackTrace();
           return ResultVo.error(e.getMessage());
       }
    }

}
